package com.dmpp.mes.service.impl;


import com.dmpp.mes.bean.ResponseData;
import com.dmpp.mes.dao.ProcessMapper;
import com.dmpp.mes.dao.ProductMapper;
import com.dmpp.mes.parameterInfo.Process;
import com.dmpp.mes.parameterInfo.Product;
import com.dmpp.mes.service.ProcessService;
import com.dmpp.mes.service.ProductService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service(value = "ProductService")
public class ProductServiceImpl implements ProductService {


    @Autowired
    private ProductMapper mapper;

    @Override
    public ResponseData findAll(Product product) {
        ResponseData responseData = new ResponseData();
        PageInfo pageInfo = new PageInfo<>(mapper.findAll(product));
        responseData.setData(pageInfo);
        return responseData;
    }

    @Override
    public ResponseData findById(String id) {
        ResponseData responseData = new ResponseData();
        responseData.setData(mapper.findById(id));
        return responseData;
    }

   /* @Override
    public ResponseData findByCode(String code) {
        ResponseData responseData = new ResponseData();
        responseData.setData(mapper.findByCode(code));
        return responseData;
    }*/

    @Override
    public ResponseData insert(Product product) {
        ResponseData responseData = new ResponseData();
        mapper.insert(product);
        return responseData;
    }

    @Override
    public ResponseData updateById(Product product) {
        ResponseData responseData = new ResponseData();
        mapper.updateById(product);
        return responseData;
    }

    @Override
    public ResponseData deleteById(String id) {
        ResponseData responseData = new ResponseData();
        mapper.deleteById(id);
        return responseData;
    }

    @Override
    public ResponseData altogether(Product product) {
        ResponseData responseData = new ResponseData();
        responseData.setData(mapper.altogether(product));
        return responseData;
    }

    @Override
    public ResponseData semiFindAll(Product product) {
        ResponseData responseData = new ResponseData();
        PageInfo pageInfo = new PageInfo<>(mapper.semiFindAll(product));
        responseData.setData(pageInfo);
        return responseData;
    }


    /*@Override
    public ResponseData delete(String code) {
        ResponseData responseData = new ResponseData();
        mapper.delete(code);
        return responseData;
    }*/
}
